package com.interview.content.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.interview.common.utils.PageUtils;
import com.interview.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.interview.content.entity.CmsInterviewImgEntity;
import com.interview.content.service.CmsInterviewImgService;



/**
 * 内容-分享的图片库
 *
 * @author bin.z
 * @email bin.z@gmail.com
 * @date 2021-05-07 01:49:40
 */
@RestController
@RequestMapping("content/cmsinterviewimg")
public class CmsInterviewImgController {
    @Autowired
    private CmsInterviewImgService cmsInterviewImgService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cmsInterviewImgService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		CmsInterviewImgEntity cmsInterviewImg = cmsInterviewImgService.getById(id);

        return R.ok().put("cmsInterviewImg", cmsInterviewImg);
    }

    /**
     * 文章图片信息
     */
    @RequestMapping("/article/{id}")
    public R article(@PathVariable("id") Long id){
        List<CmsInterviewImgEntity> imgeLists = cmsInterviewImgService.getAllById(id);

        return R.ok().put("imgeLists", imgeLists);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CmsInterviewImgEntity cmsInterviewImg){
		cmsInterviewImgService.save(cmsInterviewImg);

        return R.ok();
    }

    /**
     * 批量保存
     */
    @RequestMapping("/saveBatch")
    public R saveBatch(@RequestBody List<CmsInterviewImgEntity> interviewImgEntities){
        cmsInterviewImgService.saveBatch(interviewImgEntities);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CmsInterviewImgEntity cmsInterviewImg){
		cmsInterviewImgService.updateById(cmsInterviewImg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		cmsInterviewImgService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
